<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>活动详情</title>
    <link rel="stylesheet" href="/backstage/css/all_style.css"/>
    <link rel="stylesheet" href="/backstage/css/course_style.css"/>
    <script src="/backstage/js/jquery-1.7.1.min.js"></script>
    <script src="/backstage/js/mysel.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/index.js"></script>

    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./lib/layui/css/layui.css">
</head>
<body>

<div class="container">
    <div class="clear" style="margin-top: 20px"></div>
    <div class="cou_head">
        <dl>
            <dt>
                <img id="ator" src="./images/cou.jpg" alt=""/>
                <b id="state"></b>
            </dt>
            <dd>
                <div class="cou_tit">
                    <h3 id="title"></h3>
                </div>
                <ul>
                    <li>活动类型:<span id="type"></span></li>
                    <li>活动时间:<span id="time"></span> 可报名人数：<span id="number"></span></li>
                    <li>开始报名:<span id="start"></span>截止报名:<span id="end"></span></li>
                    <li>承办机构:<span id="org"></span></li>
                    <li>活动地点: <span id="position"><span></li>
                </ul>
                <div class="cor_btn cor_btn_one cor_ok">

                </div>
            </dd>
        </dl>
    </div>

    <div class="cou_jie">
        <div class="cou_jie_list left">
            <ul class="cou_jie_tab">
                <li>活动简介</li>
            </ul>
            <div class="cou_jie_con">
                <div class="cou_jie_shao">
                    <div class="content">
                        <p>

                        </p>

                    </div>
                </div>
            </div>
        </div>
        <div class="clear"></div>
    </div>
</div>

<div id="div_test" class="layui-bg-gray" style="width:60%;padding: 30px;display: none; position: absolute;left: 25%; top:100px" >
    <div class="layui-row layui-col-space12">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">审核活动</div>
                <div class="layui-card-body">
                    <form class="layui-form" action="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">结果</label>
                            <div class="layui-input-block">
                                <input type="checkbox" checked="" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="通过|不通过">
                           <input type="text" id="code" name="id" hidden>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text" id="desc">
                            <label class="layui-form-label">原因：</label>
                            <div class="layui-input-block">
                                <textarea placeholder="请输入内容" class="layui-textarea" name="desc"></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                                <button type="button" class="layui-btn layui-btn-normal" onclick="disappeare()">关闭</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>

    </div>

<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            ,$=layui.jquery
            , laydate = layui.laydate;
        //监听指定开关
        form.on('switch(switchTest)', function (data) {
            if(this.checked==false){
                document.getElementById('desc').style.display = 'block'
            }else {
                document.getElementById('desc').style.display = 'none'
                $("[name='desc']").val("");
            }
        });
        //监听提交
        form.on('submit(demo1)', function (data) {

            var param=  data.field
            var id= $("#code").val();
            param.id=id;
            $.getJSON("/admin/activity?opr=check",param, function (data) {
                layer.msg(data)
                // 重新加载页面
                loadData($,id);
                // 清除 未通过原因的文字数据
                $("[name='desc']").val("");
                document.getElementById('div_test').style.display = 'none'
                window.parent.location.reload();
            })
            return false;
        });


    })


    function operate() {
        document.getElementById('div_test').style.display = 'block'
        document.getElementById('desc').style.display = 'none'

        //  setTimeout('disappeare()', 2000)
    }

    function disappeare() {
        document.getElementById('div_test').style.display = 'none'
    }
</script>

<script>

    jQuery.noConflict();
    jQuery(document).ready(function ($) {
        var id = window.location.search.substr(1);
        $("#code").val(id);
        // 加载活动信息
        loadData($,id);
    })

    function loadData($,id){
        $.getJSON("/admin/activity?opr=byid&id=" + id, function (data) {
            $("#title").html(data.title);
            if (data.checked == "0") {
                $("#state").html("<span>未审核</span>");
                $(".cor_ok").html(` <a href="javascript:void(0)"
                    onclick="javascript:operate()"
                >立即审核</a>`);
            } else if (data.checked == "1") {
                $("#state").html("<span style='color: green'>审核通过</span>");
                $(".cor_ok").html(` <a href="javascript:void(0)"
                >已审核</a>`);
            } else {
                $("#state").html("<span style='color: red'>审核未通过</span>");
                $(".cor_ok").html(`<a href="javascript:void(0)"
                >未通过</a>`);
            }

            $("#type").html(data.typeName);
            $("#time").html(data.actionTime);
            $("#number").html(data.apply_people_num);
            $("#start").html(data.apply_time);
            $("#end").html(data.apply_end_time);
            $("#org").html(data.pbName);
            $("#position").html(data.position);
            $("#ator").attr("src", data.img);
            $(".content").html(data.detail)


        })

    }
</script>


</body>
</html>
